<%@ page language="java"
	import="java.util.*,bc.swim2.ejb.entity.RegisteredUser,bc.swim2.ejb.entity.Ability"
	contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	RegisteredUser currentUser = (RegisteredUser) (session
			.getAttribute("currentSessionUser"));
	if (currentUser == null) {
%>
<body>Where are you going?
</body>
<%
	} else {
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MyHome</title>
<style>
@import url(css/main.css);
</style>
</head>
<body>
	<div id="allContainer">
		<div id="titleContainer">
			<%%>
			<img src="img/swimScritta.gif" id="imageFloat" width=100px;
				height="100px">
			<h1 id="userHomeTitle">
				Welcome,
				<%=currentUser.getFirstName() + " "
						+ currentUser.getLastName()%>!
			</h1>
		</div>
		<div id="container">
			<div id="navigationContainer">
				<a href="MainServlet?to=RegisteredUserHome" id="linkRef">Home</a> <br />
				<a href="MainServlet?to=SearchHelp" id="linkRef">Search Help</a> <br />
				<a href="MainServlet?to=SearchUsers" id="linkRef">Search Users</a> <br />
				<a href="MainServlet?to=MyAbilities" id="linkRef">Declare/Remove
					ability</a> <br /> <a href="MainServlet?to=FriendshipRequests"
					id="linkRef">Friendship Requests</a> <br /> <a
					href="MainServlet?to=Friends" id="linkRef">Your Friends</a> <br />
				<a href="MainServlet?to=MyFeedback" id="linkRef">Feedback</a> <br />
				<a href="MainServlet?to=AbilityRequest" id="linkRef">Ability
					Request</a> <br /> <a href="LoginServlet?methodName=logout"
					id="linkRef">Logout</a>
			</div>
			<div id="actionContainer">

				<%
					List<RegisteredUser> fnv = null;
						fnv = (List<RegisteredUser>) request
								.getAttribute("friendsNotVisualized");
						Map<Integer, Boolean> indMap = (Map<Integer, Boolean>) request
								.getAttribute("indirectMap");
						if (!(fnv.isEmpty())) {
							for (RegisteredUser regu : fnv) {
								String firstname = regu.getFirstName();
								String lastname = regu.getLastName();
								int frid = regu.getId();
				%>
				<table>
					<tr>
						<td><%=firstname + " " + lastname + " "
								+ "has accepted your friendship! "%></td>
						<%
							if (!(indMap.get(frid))) {
						%>
						<td><a
							href="FriendshipServlet?methodName=showSuggests&acceptedFriendId=<%=frid%>"
							id="linkRefA">Maybe you know...</a></td>

						<%
							} else {
						%>
						<td><a
							href="FriendshipServlet?methodName=visualizedNewFriend&acceptedFriendId=<%=frid%>"
							id="linkRefA">Ok</a></td>
						<%
							}
						%>
					</tr>
				</table>
				<%
					}

						}
				%>

				<h1 id="listTitle">Profile informations:</h1>
				<label id="listLabelA">Username:</label>
				<%=currentUser.getUsername()%>
				<br> <label id="listLabelA">Email:</label>
				<%=currentUser.getEmail()%>
				<br> <label id="listLabelA">Birth date:</label>
				<%=currentUser.getBirthDate()%>
				<br> <br>
				<h1 id="listTitle">Your abilities:</h1>
				<%
					List<Ability> abilities = null;
						abilities = (List<Ability>) request.getAttribute("abilityList");
						Iterator<Ability> it = abilities.iterator();
				%><table>
					<%
						while (it.hasNext()) {

								Ability a = (Ability) (it.next());
								String name = a.getName();
					%>
					<tr>
						<td><%=name%></td>
					</tr>

					<%
						}
					%>
				</table>
			</div>
		</div>
	</div>
</body>
<%
	}
%>

</html>